home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / SASC_6.0_Disk_4.adf / Compiler_Headers / Include / dos / dosextens.h < prev    next >
C/C++ Source or Header  |  1992-07-30  |  17KB  |  493 lines

  1. #ifndef DOS_DOSEXTENS_H
  2. #define DOS_DOSEXTENS_H
  3. /*
  4. **    $Filename: dos/dosextens.h $
  5. **    $Release: 2.04 Includes, V37.4 $
  6. **    $Revision: 36.38 $
  7. **    $Date: 91/11/08 $
  8. **
  9. **    DOS structures not needed for the casual AmigaDOS user
  10. **
  11. **    (C) Copyright 1985-1991 Commodore-Amiga, Inc.
  12. **        All Rights Reserved
  13. */
  14.  
  15. #ifndef EXEC_TASKS_H
  16. #include "exec/tasks.h"
  17. #endif
  18. #ifndef EXEC_PORTS_H
  19. #include "exec/ports.h"
  20. #endif
  21. #ifndef EXEC_LIBRARIES_H
  22. #include "exec/libraries.h"
  23. #endif
  24. #ifndef EXEC_SEMAPHORES_H
  25. #include "exec/semaphores.h"
  26. #endif
  27. #ifndef DEVICES_TIMER_H
  28. #include "devices/timer.h"
  29. #endif
  30.  
  31. #ifndef DOS_DOS_H
  32. #include "dos/dos.h"
  33. #endif
  34.  
  35. /* All DOS processes have this structure */
  36. /* Create and Device Proc returns pointer to the MsgPort in this structure */
  37. /* dev_proc = (struct Process *) (DeviceProc(..) - sizeof(struct Task)); */
  38.  
  39. struct Process {
  40.     struct  Task    pr_Task;
  41.     struct  MsgPort pr_MsgPort; /* This is BPTR address from DOS functions  */
  42.     WORD    pr_Pad;        /* Remaining variables on 4 byte boundaries */
  43.     BPTR    pr_SegList;        /* Array of seg lists used by this process  */
  44.     LONG    pr_StackSize;    /* Size of process stack in bytes        */
  45.     APTR    pr_GlobVec;        /* Global vector for this process (BCPL)    */
  46.     LONG    pr_TaskNum;        /* CLI task number of zero if not a CLI        */
  47.     BPTR    pr_StackBase;    /* Ptr to high memory end of process stack  */
  48.     LONG    pr_Result2;        /* Value of secondary result from last call */
  49.     BPTR    pr_CurrentDir;    /* Lock associated with current directory   */
  50.     BPTR    pr_CIS;        /* Current CLI Input Stream            */
  51.     BPTR    pr_COS;        /* Current CLI Output Stream            */
  52.     APTR    pr_ConsoleTask;    /* Console handler process for current window*/
  53.     APTR    pr_FileSystemTask;    /* File handler process for current drive   */
  54.     BPTR    pr_CLI;        /* pointer to CommandLineInterface        */
  55.     APTR    pr_ReturnAddr;    /* pointer to previous stack frame        */
  56.     APTR    pr_PktWait;        /* Function to be called when awaiting msg  */
  57.     APTR    pr_WindowPtr;    /* Window for error printing            */
  58.  
  59.     /* following definitions are new with 2.0 */
  60.     BPTR    pr_HomeDir;        /* Home directory of executing program        */
  61.     LONG    pr_Flags;        /* flags telling dos about process        */
  62.     void    (*pr_ExitCode)();    /* code to call on exit of program or NULL  */
  63.     LONG    pr_ExitData;    /* Passed as an argument to pr_ExitCode.    */
  64.     UBYTE   *pr_Arguments;    /* Arguments passed to the process at start */
  65.     struct MinList pr_LocalVars; /* Local environment variables            */
  66.     ULONG   pr_ShellPrivate;    /* for the use of the current shell        */
  67.     BPTR    pr_CES;        /* Error stream - if NULL, use pr_COS        */
  68. };  /* Process */
  69.  
  70. /*
  71.  * Flags for pr_Flags
  72.  */
  73. #define    PRB_FREESEGLIST        0
  74. #define    PRF_FREESEGLIST        1
  75. #define    PRB_FREECURRDIR        1
  76. #define    PRF_FREECURRDIR        2
  77. #define    PRB_FREECLI        2
  78. #define    PRF_FREECLI        4
  79. #define    PRB_CLOSEINPUT        3
  80. #define    PRF_CLOSEINPUT        8
  81. #define    PRB_CLOSEOUTPUT        4
  82. #define    PRF_CLOSEOUTPUT        16
  83. #define    PRB_FREEARGS        5
  84. #define    PRF_FREEARGS        32
  85.  
  86. /* The long word address (BPTR) of this structure is returned by
  87.  * Open() and other routines that return a file.  You need only worry
  88.  * about this struct to do async io's via PutMsg() instead of
  89.  * standard file system calls */
  90.  
  91. struct FileHandle {
  92.    struct Message *fh_Link;     /* EXEC message          */
  93.    struct MsgPort *fh_Port;     /* Reply port for the packet */
  94.    struct MsgPort *fh_Type;     /* Port to do PutMsg() to
  95.                   * Address is negative if a plain file */
  96.    LONG fh_Buf;
  97.    LONG fh_Pos;
  98.    LONG fh_End;
  99.    LONG fh_Funcs;
  100. #define fh_Func1 fh_Funcs
  101.    LONG fh_Func2;
  102.    LONG fh_Func3;
  103.    LONG fh_Args;
  104. #define fh_Arg1 fh_Args
  105.    LONG fh_Arg2;
  106. }; /* FileHandle */
  107.  
  108. /* This is the extension to EXEC Messages used by DOS */
  109.  
  110. struct DosPacket {
  111.    struct Message *dp_Link;     /* EXEC message          */
  112.    struct MsgPort *dp_Port;     /* Reply port for the packet */
  113.                  /* Must be filled in each send. */
  114.    LONG dp_Type;         /* See ACTION_... below and
  115.                   * 'R' means Read, 'W' means Write to the
  116.                   * file system */
  117.    LONG dp_Res1;         /* For file system calls this is the result
  118.                   * that would have been returned by the
  119.                   * function, e.g. Write ('W') returns actual
  120.                   * length written */
  121.    LONG dp_Res2;         /* For file system calls this is what would
  122.                   * have been returned by IoErr() */
  123. /*  Device packets common equivalents */
  124. #define dp_Action  dp_Type
  125. #define dp_Status  dp_Res1
  126. #define dp_Status2 dp_Res2
  127. #define dp_BufAddr dp_Arg1
  128.    LONG dp_Arg1;
  129.    LONG dp_Arg2;
  130.    LONG dp_Arg3;
  131.    LONG dp_Arg4;
  132.    LONG dp_Arg5;
  133.    LONG dp_Arg6;
  134.    LONG dp_Arg7;
  135. }; /* DosPacket */
  136.  
  137. /* A Packet does not require the Message to be before it in memory, but
  138.  * for convenience it is useful to associate the two.
  139.  * Also see the function init_std_pkt for initializing this structure */
  140.  
  141. struct StandardPacket {
  142.    struct Message   sp_Msg;
  143.    struct DosPacket sp_Pkt;
  144. }; /* StandardPacket */
  145.  
  146. /* Packet types */
  147. #define ACTION_NIL        0
  148. #define ACTION_STARTUP        0
  149. #define ACTION_GET_BLOCK    2    /* OBSOLETE */
  150. #define ACTION_SET_MAP        4
  151. #define ACTION_DIE        5
  152. #define ACTION_EVENT        6
  153. #define ACTION_CURRENT_VOLUME    7
  154. #define ACTION_LOCATE_OBJECT    8
  155. #define ACTION_RENAME_DISK    9
  156. #define ACTION_WRITE        'W'
  157. #define ACTION_READ        'R'
  158. #define ACTION_FREE_LOCK    15
  159. #define ACTION_DELETE_OBJECT    16
  160. #define ACTION_RENAME_OBJECT    17
  161. #define ACTION_MORE_CACHE    18
  162. #define ACTION_COPY_DIR        19
  163. #define ACTION_WAIT_CHAR    20
  164. #define ACTION_SET_PROTECT    21
  165. #define ACTION_CREATE_DIR    22
  166. #define ACTION_EXAMINE_OBJECT    23
  167. #define ACTION_EXAMINE_NEXT    24
  168. #define ACTION_DISK_INFO    25
  169. #define ACTION_INFO        26
  170. #define ACTION_FLUSH        27
  171. #define ACTION_SET_COMMENT    28
  172. #define ACTION_PARENT        29
  173. #define ACTION_TIMER        30
  174. #define ACTION_INHIBIT        31
  175. #define ACTION_DISK_TYPE    32
  176. #define ACTION_DISK_CHANGE    33
  177. #define ACTION_SET_DATE        34
  178.  
  179. #define ACTION_SCREEN_MODE    994
  180.  
  181. #define ACTION_READ_RETURN    1001
  182. #define ACTION_WRITE_RETURN    1002
  183. #define ACTION_SEEK        1008
  184. #define ACTION_FINDUPDATE    1004
  185. #define ACTION_FINDINPUT    1005
  186. #define ACTION_FINDOUTPUT    1006
  187. #define ACTION_END        1007
  188. #define ACTION_SET_FILE_SIZE    1022    /* fast file system only in 1.3 */
  189. #define ACTION_WRITE_PROTECT    1023    /* fast file system only in 1.3 */
  190.  
  191. /* new 2.0 packets */
  192. #define ACTION_SAME_LOCK    40
  193. #define ACTION_CHANGE_SIGNAL    995
  194. #define ACTION_FORMAT        1020
  195. #define ACTION_MAKE_LINK    1021
  196. /**/
  197. /**/
  198. #define ACTION_READ_LINK    1024
  199. #define ACTION_FH_FROM_LOCK    1026
  200. #define ACTION_IS_FILESYSTEM    1027
  201. #define ACTION_CHANGE_MODE    1028
  202. /**/
  203. #define ACTION_COPY_DIR_FH    1030
  204. #define ACTION_PARENT_FH    1031
  205. #define ACTION_EXAMINE_ALL    1033
  206. #define ACTION_EXAMINE_FH    1034
  207.  
  208. #define ACTION_LOCK_RECORD    2008
  209. #define ACTION_FREE_RECORD    2009
  210.  
  211. #define ACTION_ADD_NOTIFY    4097
  212. #define ACTION_REMOVE_NOTIFY    4098
  213.  
  214. /* Tell a file system to serialize the current volume. This is typically
  215.  * done by changing the creation date of the disk. This packet does not take
  216.  * any arguments.  NOTE: be prepared to handle failure of this packet for
  217.  * V37 ROM filesystems.
  218.  */
  219. #define    ACTION_SERIALIZE_DISK    4200
  220.  
  221. /*
  222.  * A structure for holding error messages - stored as array with error == 0
  223.  * for the last entry.
  224.  */
  225. struct ErrorString {
  226.     LONG  *estr_Nums;
  227.     UBYTE *estr_Strings;
  228. };
  229.  
  230. /* DOS library node structure.
  231.  * This is the data at positive offsets from the library node.
  232.  * Negative offsets from the node is the jump table to DOS functions
  233.  * node = (struct DosLibrary *) OpenLibrary( "dos.library" .. )         */
  234.  
  235. struct DosLibrary {
  236.     struct Library dl_lib;
  237.     struct RootNode *dl_Root; /* Pointer to RootNode, described below */
  238.     APTR    dl_GV;          /* Pointer to BCPL global vector          */
  239.     LONG    dl_A2;          /* BCPL standard register values          */
  240.     LONG    dl_A5;
  241.     LONG    dl_A6;
  242.     struct ErrorString *dl_Errors;      /* PRIVATE pointer to array of error msgs */
  243.     struct timerequest *dl_TimeReq;      /* PRIVATE pointer to timer request */
  244.     struct Library     *dl_UtilityBase;   /* PRIVATE ptr to utility library */
  245.     struct Library     *dl_IntuitionBase; /* PRIVATE ptr to intuition library */
  246. };  /*    DosLibrary */
  247.  
  248. /*                   */
  249.  
  250. struct RootNode {
  251.     BPTR    rn_TaskArray;         /* [0] is max number of CLI's
  252.                       * [1] is APTR to process id of CLI 1
  253.                       * [n] is APTR to process id of CLI n */
  254.     BPTR    rn_ConsoleSegment; /* SegList for the CLI               */
  255.     struct  DateStamp rn_Time; /* Current time                   */
  256.     LONG    rn_RestartSeg;     /* SegList for the disk validator process   */
  257.     BPTR    rn_Info;           /* Pointer to the Info structure           */
  258.     BPTR    rn_FileHandlerSegment; /* segment for a file handler       */
  259.     struct MinList rn_CliList; /* new list of all CLI processes */
  260.                    /* the first cpl_Array is also rn_TaskArray */
  261.     struct MsgPort *rn_BootProc; /* private ptr to msgport of boot fs       */
  262.     BPTR    rn_ShellSegment;   /* seglist for Shell (for NewShell)       */
  263.     LONG    rn_Flags;           /* dos flags */
  264. };  /* RootNode */
  265.  
  266. #define RNB_WILDSTAR    24
  267. #define RNF_WILDSTAR    (1L<<24)
  268. #define RNB_PRIVATE1    1    /* private for dos */
  269. #define RNF_PRIVATE1    2
  270.  
  271. /* ONLY to be allocated by DOS! */
  272. struct CliProcList {
  273.     struct MinNode cpl_Node;
  274.     LONG cpl_First;         /* number of first entry in array */
  275.     struct MsgPort **cpl_Array;
  276.                  /* [0] is max number of CLI's in this entry (n)
  277.                   * [1] is CPTR to process id of CLI cpl_First
  278.                   * [n] is CPTR to process id of CLI cpl_First+n-1
  279.                   */
  280. };
  281.  
  282. struct DosInfo {
  283.     BPTR    di_McName;           /* PRIVATE: system resident module list        */
  284. #define di_ResList di_McName
  285.     BPTR    di_DevInfo;           /* Device List                    */
  286.     BPTR    di_Devices;           /* Currently zero                */
  287.     BPTR    di_Handlers;       /* Currently zero                */
  288.     APTR    di_NetHand;           /* Network handler processid; currently zero */
  289.     struct  SignalSemaphore di_DevLock;       /* do NOT access directly! */
  290.     struct  SignalSemaphore di_EntryLock;  /* do NOT access directly! */
  291.     struct  SignalSemaphore di_DeleteLock; /* do NOT access directly! */
  292. };  /* DosInfo */
  293.  
  294. /* structure for the Dos resident list.  Do NOT allocate these, use      */
  295. /* AddSegment(), and heed the warnings in the autodocs!              */
  296.  
  297. struct Segment {
  298.     BPTR seg_Next;
  299.     LONG seg_UC;
  300.     BPTR seg_Seg;
  301.     UBYTE seg_Name[4];    /* actually the first 4 chars of BSTR name */
  302. };
  303.  
  304. #define CMD_SYSTEM    -1
  305. #define CMD_INTERNAL    -2
  306. #define CMD_DISABLED    -999
  307.  
  308.  
  309. /* DOS Processes started from the CLI via RUN or NEWCLI have this additional
  310.  * set to data associated with them */
  311.  
  312. struct CommandLineInterface {
  313.     LONG   cli_Result2;           /* Value of IoErr from last command      */
  314.     BSTR   cli_SetName;           /* Name of current directory          */
  315.     BPTR   cli_CommandDir;     /* Head of the path locklist          */
  316.     LONG   cli_ReturnCode;     /* Return code from last command          */
  317.     BSTR   cli_CommandName;    /* Name of current command          */
  318.     LONG   cli_FailLevel;      /* Fail level (set by FAILAT)          */
  319.     BSTR   cli_Prompt;           /* Current prompt (set by PROMPT)      */
  320.     BPTR   cli_StandardInput;  /* Default (terminal) CLI input          */
  321.     BPTR   cli_CurrentInput;   /* Current CLI input              */
  322.     BSTR   cli_CommandFile;    /* Name of EXECUTE command file          */
  323.     LONG   cli_Interactive;    /* Boolean; True if prompts required      */
  324.     LONG   cli_Background;     /* Boolean; True if CLI created by RUN      */
  325.     BPTR   cli_CurrentOutput;  /* Current CLI output              */
  326.     LONG   cli_DefaultStack;   /* Stack size to be obtained in long words */
  327.     BPTR   cli_StandardOutput; /* Default (terminal) CLI output          */
  328.     BPTR   cli_Module;           /* SegList of currently loaded command      */
  329. };  /* CommandLineInterface */
  330.  
  331. /* This structure can take on different values depending on whether it is
  332.  * a device, an assigned directory, or a volume.  Below is the structure
  333.  * reflecting volumes only.  Following that is the structure representing
  334.  * only devices. Following that is the unioned structure representing all
  335.  * the values
  336.  */
  337.  
  338. /* structure representing a volume */
  339.  
  340. struct DeviceList {
  341.     BPTR        dl_Next;    /* bptr to next device list */
  342.     LONG        dl_Type;    /* see DLT below */
  343.     struct MsgPort *    dl_Task;    /* ptr to handler task */
  344.     BPTR        dl_Lock;    /* not for volumes */
  345.     struct DateStamp    dl_VolumeDate;    /* creation date */
  346.     BPTR        dl_LockList;    /* outstanding locks */
  347.     LONG        dl_DiskType;    /* 'DOS', etc */
  348.     LONG        dl_unused;
  349.     BSTR        dl_Name;    /* bptr to bcpl name */
  350. };
  351.  
  352. /* device structure (same as the DeviceNode structure in filehandler.h) */
  353.  
  354. struct          DevInfo {
  355.     BPTR  dvi_Next;
  356.     LONG  dvi_Type;
  357.     APTR  dvi_Task;
  358.     BPTR  dvi_Lock;
  359.     BSTR  dvi_Handler;
  360.     LONG  dvi_StackSize;
  361.     LONG  dvi_Priority;
  362.     LONG  dvi_Startup;
  363.     BPTR  dvi_SegList;
  364.     BPTR  dvi_GlobVec;
  365.     BSTR  dvi_Name;
  366. };
  367.  
  368. /* combined structure for devices, assigned directories, volumes */
  369.  
  370. struct DosList {
  371.     BPTR        dol_Next;     /* bptr to next device on list */
  372.     LONG        dol_Type;     /* see DLT below */
  373.     struct MsgPort     *dol_Task;     /* ptr to handler task */
  374.     BPTR        dol_Lock;
  375.     union {
  376.     struct {
  377.     BSTR    dol_Handler;    /* file name to load if seglist is null */
  378.     LONG    dol_StackSize;    /* stacksize to use when starting process */
  379.     LONG    dol_Priority;    /* task priority when starting process */
  380.     ULONG    dol_Startup;    /* startup msg: FileSysStartupMsg for disks */
  381.     BPTR    dol_SegList;    /* already loaded code for new task */
  382.     BPTR    dol_GlobVec;    /* BCPL global vector to use when starting
  383.                  * a process. -1 indicates a C/Assembler
  384.                  * program. */
  385.     } dol_handler;
  386.  
  387.     struct {
  388.     struct DateStamp    dol_VolumeDate;     /* creation date */
  389.     BPTR            dol_LockList;     /* outstanding locks */
  390.     LONG            dol_DiskType;     /* 'DOS', etc */
  391.     } dol_volume;
  392.  
  393.     struct {
  394.     UBYTE    *dol_AssignName;     /* name for non-or-late-binding assign */
  395.     struct AssignList *dol_List; /* for multi-directory assigns (regular) */
  396.     } dol_assign;
  397.  
  398.     } dol_misc;
  399.  
  400.     BSTR        dol_Name;     /* bptr to bcpl name */
  401.     };
  402.  
  403. /* structure used for multi-directory assigns. AllocVec()ed. */
  404.  
  405. struct AssignList {
  406.     struct AssignList *al_Next;
  407.     BPTR           al_Lock;
  408. };
  409.  
  410. /* definitions for dl_Type */
  411. #define DLT_DEVICE    0
  412. #define DLT_DIRECTORY    1    /* assign */
  413. #define DLT_VOLUME    2
  414. #define DLT_LATE    3    /* late-binding assign */
  415. #define DLT_NONBINDING    4    /* non-binding assign */
  416. #define DLT_PRIVATE    -1    /* for internal use only */
  417.  
  418. /* structure return by GetDeviceProc() */
  419. struct DevProc {
  420.     struct MsgPort *dvp_Port;
  421.     BPTR        dvp_Lock;
  422.     ULONG        dvp_Flags;
  423.     struct DosList *dvp_DevNode;    /* DON'T TOUCH OR USE! */
  424. };
  425.  
  426. /* definitions for dvp_Flags */
  427. #define DVPB_UNLOCK    0
  428. #define DVPF_UNLOCK    (1L << DVPB_UNLOCK)
  429. #define DVPB_ASSIGN    1
  430. #define DVPF_ASSIGN    (1L << DVPB_ASSIGN)
  431.  
  432. /* Flags to be passed to LockDosList(), etc */
  433. #define LDB_DEVICES    2
  434. #define LDF_DEVICES    (1L << LDB_DEVICES)
  435. #define LDB_VOLUMES    3
  436. #define LDF_VOLUMES    (1L << LDB_VOLUMES)
  437. #define LDB_ASSIGNS    4
  438. #define LDF_ASSIGNS    (1L << LDB_ASSIGNS)
  439. #define LDB_ENTRY    5
  440. #define LDF_ENTRY    (1L << LDB_ENTRY)
  441. #define LDB_DELETE    6
  442. #define LDF_DELETE    (1L << LDB_DELETE)
  443.  
  444. /* you MUST specify one of LDF_READ or LDF_WRITE */
  445. #define LDB_READ    0
  446. #define LDF_READ    (1L << LDB_READ)
  447. #define LDB_WRITE    1
  448. #define LDF_WRITE    (1L << LDB_WRITE)
  449.  
  450. /* actually all but LDF_ENTRY (which is used for internal locking) */
  451. #define LDF_ALL        (LDF_DEVICES|LDF_VOLUMES|LDF_ASSIGNS)
  452.  
  453. /* a lock structure, as returned by Lock() or DupLock() */
  454. struct FileLock {
  455.     BPTR        fl_Link;    /* bcpl pointer to next lock */
  456.     LONG        fl_Key;        /* disk block number */
  457.     LONG        fl_Access;    /* exclusive or shared */
  458.     struct MsgPort *    fl_Task;    /* handler task's port */
  459.     BPTR        fl_Volume;    /* bptr to DLT_VOLUME DosList entry */
  460. };
  461.  
  462. /* error report types for ErrorReport() */
  463. #define REPORT_STREAM        0    /* a stream */
  464. #define REPORT_TASK        1    /* a process - unused */
  465. #define REPORT_LOCK        2    /* a lock */
  466. #define REPORT_VOLUME        3    /* a volume node */
  467. #define REPORT_INSERT        4    /* please insert volume */
  468.  
  469. /* Special error codes for ErrorReport() */
  470. #define ABORT_DISK_ERROR    296    /* Read/write error */
  471. #define ABORT_BUSY        288    /* You MUST replace... */
  472.  
  473. /* types for initial packets to shells from run/newcli/execute/system. */
  474. /* For shell-writers only */
  475. #define RUN_EXECUTE        -1
  476. #define RUN_SYSTEM        -2
  477. #define RUN_SYSTEM_ASYNCH    -3
  478.  
  479. /* Types for fib_DirEntryType.    NOTE that both USERDIR and ROOT are     */
  480. /* directories, and that directory/file checks should use <0 and >=0.     */
  481. /* This is not necessarily exhaustive!    Some handlers may use other     */
  482. /* values as needed, though <0 and >=0 should remain as supported as     */
  483. /* possible.                                 */
  484. #define ST_ROOT        1
  485. #define ST_USERDIR    2
  486. #define ST_SOFTLINK    3    /* looks like dir, but may point to a file! */
  487. #define ST_LINKDIR    4    /* hard link to dir */
  488. #define ST_FILE        -3    /* must be negative for FIB! */
  489. #define ST_LINKFILE    -4    /* hard link to file */
  490. #define ST_PIPEFILE    -5    /* for pipes that support ExamineFH */
  491.  
  492. #endif    /* DOS_DOSEXTENS_H */
  493.